from dbshop1.public.action import *
from dbshop1.public.business import *
from selenium.webdriver.common.keys import Keys
from dbshop1.public.testData import *
from dbshop1.public.tools import*
testCase="DBshop031_编辑标签"
#打开网页并实例化
llq=openBrowser(urlAdmin)
#登入后台页面
DBshopLoginAdmin(llq)
#进入标签组页面
DBshopEnterMenu3(llq,"商品管理","商品标签","商品标签分组")
#通过属性名定位就行编辑
llq.find_element_by_xpath('//td[contains(.,"华为手机，华为耳机")]/following-sibling::td[3]/a[1]').click()#xpath轴定位
llq.find_element_by_xpath('//select[@id="tag_group_id"]/option[3]').click()
llq.find_element_by_id("tag_name").send_keys("小米第二")
llq.find_element_by_id("tag_sort").send_keys(Keys.BACK_SPACE*4)
llq.find_element_by_id("tag_sort").send_keys("2")
llq.find_element_by_xpath('//button[@class="btn btn-small btn-primary"]').click()
try:
    llq.find_element_by_xpath('//td[contains(.,"小米第二")]')
    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(llq)
llq.quit()